package cjq.demo.spring.aop2;

import org.junit.Test;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.lang.reflect.Method;

/**
 * author: cjianquan
 * date: 2016/9/14
 */
public class ARAdviceDemo implements AfterReturningAdvice {
    public void cut1(){
        System.out.println("ARAdviceDemo:cut1");
    }
    public void cut(){
        System.out.println("ARAdviceDemo:cut");
    }
    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        System.out.println("ARAdviceDemo:afterReturning");
    }

    @Test
    public void test_cut1(){
        ApplicationContext appContext = new ClassPathXmlApplicationContext(
                new String[] { "spring-aop2.xml" });
        ARAdviceDemo demo = (ARAdviceDemo)appContext.getBean("aRAdviceDemo");
        demo.cut1();
    }
}
